package com.jnshu.service.Impl;

import com.jnshu.dao.StuDao;

import com.jnshu.entity.Student;
import com.jnshu.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("stuService")
public class StudentServiceImpl implements StudentService {
   /*
   * 自动注入StuDao
   * */
    @Autowired
    private StuDao stuDao;

    @Override
    public Student findUserById(Integer sid) {
        return stuDao.findUserById(sid);
    }

    @Override
    public List<Student> findUserByUsername(String sname) {
        return stuDao.findUserByUsername(sname);
    }

    @Override
    public void save(Student student) {
        stuDao.save(student);
    }

    @Override
    public int updateUser(Student student) {
        return stuDao.updateUser(student);
    }

    @Override
    public boolean deleteUserById(Integer sid) {
        return stuDao.deleteUserById(sid);
    }

    @Override
    public List<Student> findAll() {
        List<Student> listAll = stuDao.findAll();
        return listAll;
    }

    /* UserService接口Login方法实现*/
    @Override
    public Student login(String sname, String password) {

        return stuDao.findWithLoginnameAndPassword(sname,password);
    }

}









